'''
继承的写法：
    class A(object):
        def __init__():

    class B(A):
'''

class A():
    def __init__(self):
        self.name=1

    def print_info(self):
        print(self.name)

class B():
    def __init__(self):
        self.name=2

    def print_info(self):
        print(self.name)

class C(B,A):
    def __init__(self):
        self.name = 3

    def print_info(self):
        print(self.name)

c=C()
c.print_info()

#查找类的mro顺序
print(C.__mro__)

'''煎饼案例
子类复写父类的同名方法，***必须要调用初始化
自己也许要调用初始化
如果不加自己的初始化，会导致属性值为上次调用的值
调用父类的方法:
方法一：
父类.__init__(self)
父类.方法(self)
方法二1：
super(当前类名,self).__init__()
super(当前类名,self).函数()
方法二2：
super().__init__()
super().函数()

私有属性和方法，在前面加__
'''

class Master():
    def __init__(self):
        self.kongfu='[古法煎饼]'

    def make_cake(self):
        print(f'用{self.kongfu}制作煎饼')

    def master_print(self):
        print('master打印')


class School():
    def __init__(self):
        self.kongfu = '[学校煎饼]'

    def make_cake(self):
        print(f'用{self.kongfu}制作煎饼')

class Prentice(School,Master):
    def __init__(self):
        self.kongfu = '[独创煎饼]'
        self.__money=200000

    def get__money(self):
        return self.__money

    def set__money(self):
        self.__money=500

    def make_cake(self):
        self.__init__()
        print(f'用{self.kongfu}制作煎饼')

    def make_master_cake(self):
        Master.__init__(self)
        Master.make_cake(self)

    def make_school_cake(self):
        School.__init__(self)
        School.make_cake(self)

    def make_old_cake(self):
        #方法一
        Master.__init__(self)
        Master.make_cake(self)
        #方法二
        #1
        # super(Prentice, self).__init__()
        # super(Prentice,self).make_cake()
        #2
        super().__init__()
        super().make_cake()

    def print_info(self):
        print('打印')

class Tusun(Prentice):
    pass
daqiu=Prentice()
daqiu.make_master_cake()
daqiu.make_old_cake()

xiaoqiu=Tusun()
#无法继承私有属性，带__的属性和方法
# xiaoqiu.__money()
xiaoqiu.print_info()
xiaoqiu.master_print()
print(xiaoqiu.get__money())
xiaoqiu.set__money()
print(xiaoqiu.get__money())
# xiaoqiu.make_master_cake()
# xiaoqiu.make_school_cake()
# print(Tusun.__mro__)
